/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Javabeans;

/**
 * @author Muhammed
 * 
 */
public class Value {
    private String nominalValue=null;
    private Double realValue=null;
    private boolean isReal=true;

    public Value(String value){
        nominalValue=value;
        isReal=false;
    }

    public Value(Double value){
        realValue=value;
        isReal=true;
    }
    /**
     * @return the realValue
     */
    public Double getRealValue() {
        return realValue;
    }
    public String getNominalValue(){
        return nominalValue;
    }
    /**
     * @param realValue the realValue to set
     */
    public void setValue(Double realValue) {
        this.realValue = realValue;
        isReal=true;
    }

    /**
     * @param nominalValue the nominalValue to set
     */
    public void setValue(String nominalValue) {
        this.nominalValue = nominalValue;
        isReal=false;
    }
    
    public int compareTo(Object other) {
        Value otherValue = (Value)other;
        if(this.isReal==otherValue.isReal){
            if(this.isReal){
                return this.realValue.compareTo(otherValue.realValue);
            }else{
                return this.nominalValue.compareTo(otherValue.nominalValue);
            }
        }else{
            return -1;
        }
    }
}
